<?php
class feedback extends core {
	public function __construct() {
		parent::__construct();
	}

	//index
	public function index() {
		$where = '';
		$member_id = (isset($_GET['member_id']) && trim($_GET['member_id'])) ? intval($_GET['member_id']) : '';
		$keyword = (isset($_GET['keyword']) && trim($_GET['keyword'])) ? trim($_GET['keyword']) : '';
		if ($keyword) {
			$where .= "AND (name LIKE '%{$keyword}%' OR content LIKE '%{$keyword}%')";
		}
		if ($member_id) {
			$where .= "AND member_id='{$member_id}'";
		}
		//分页
		$this->setpages(array('member_id'=>$member_id, 'keyword'=>$keyword));

		$sql = "SELECT * ,f.id as f_id FROM jf_feedback f LEFT JOIN jf_member m ON f.member_id = m.id 
		 WHERE 1 {$where} ORDER BY f.add_time DESC";
		$rs = $this->ezr->get_results($sql);
		$nav = $this->ezr->get_navigation();
		$this->smarty->assign('rs',$rs);
		$this->smarty->assign('page',$nav);

		$this->smarty->assign('is_admin', $_SESSION['admin']->is_admin);
		$this->display();
	}
	//delete
	public function delete() {
		$id = (isset($_GET['id']) && trim($_GET['id'])) ? intval($_GET['id']) : 0;
		$sql = "DELETE FROM jf_feedback WHERE id='{$id}'";
		$this->db->query($sql);
		//exit;
		header("Location:?app=feedback&act=index");
	}
}
